package com.google.shop.product.service.impl.member;

import com.google.shop.product.entity.member.BuyerAddress;
import com.google.shop.product.repository.member.BuyerAddressRepository;
import com.google.shop.product.service.member.BuyerAddressService;
import com.google.shop.product.vo.member.BuyerAddressListVO;
import com.google.shop.product.vo.member.BuyerAddressVO;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/* loaded from: app.jar:BOOT-INF/classes/com/google/shop/product/service/impl/member/BuyerAddressImpl.class */
public class BuyerAddressImpl implements BuyerAddressService {
    @Autowired
    BuyerAddressRepository addressRepository;

    @Override // com.google.shop.product.service.member.BuyerAddressService
    public BuyerAddressListVO findBuyerAddressListBybuyerId(Integer buyerId) {
        BuyerAddressListVO buyerAddressListVO = new BuyerAddressListVO();
        buyerAddressListVO.setBuyerAddressListVOList((List) this.addressRepository.findByBuyerId(buyerId).stream().map(e -> {
            return new BuyerAddressVO(e.getId(), e.getBuyerReceiveDetailAddress(), e.getBuyerReceiveTel(), e.getBuyerReceiveName(), e.getBuyerReceiveAreaCode(), "", null);
        }).collect(Collectors.toList()));
        return buyerAddressListVO;
    }

    @Override // com.google.shop.product.service.member.BuyerAddressService
    public void saveBuyerAddress(BuyerAddressVO newAddressJSON, Integer buyerId) {
        newAddressJSON.setBuyerId(buyerId);
        BuyerAddress buyerAddress = new BuyerAddress();
        BeanUtils.copyProperties(newAddressJSON, buyerAddress);
        this.addressRepository.save(buyerAddress);
    }

    @Override // com.google.shop.product.service.member.BuyerAddressService
    public void editBuyerAddress(BuyerAddressVO editAddressJSON, Integer buyerId) {
        editAddressJSON.setBuyerId(buyerId);
        BuyerAddress buyerAddress = new BuyerAddress();
        BeanUtils.copyProperties(editAddressJSON, buyerAddress);
        this.addressRepository.save(buyerAddress);
    }

    @Override // com.google.shop.product.service.member.BuyerAddressService
    public BuyerAddress findLineById(Integer addressId) {
        return this.addressRepository.findEntityById(addressId);
    }
}
